package com.ruoyi.canteen.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.canteen.mapper.CanteenCpSpecialMapper;
import com.ruoyi.canteen.domain.CanteenCpSpecial;
import com.ruoyi.canteen.service.ICanteenCpSpecialService;

/**
 * 菜品规格Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-09-10
 */
@Service
public class CanteenCpSpecialServiceImpl implements ICanteenCpSpecialService 
{
    @Autowired
    private CanteenCpSpecialMapper canteenCpSpecialMapper;

    /**
     * 查询菜品规格
     * 
     * @param id 菜品规格主键
     * @return 菜品规格
     */
    @Override
    public CanteenCpSpecial selectCanteenCpSpecialById(Long id)
    {
        return canteenCpSpecialMapper.selectCanteenCpSpecialById(id);
    }

    /**
     * 查询菜品规格列表
     * 
     * @param canteenCpSpecial 菜品规格
     * @return 菜品规格
     */
    @Override
    public List<CanteenCpSpecial> selectCanteenCpSpecialList(CanteenCpSpecial canteenCpSpecial)
    {
        return canteenCpSpecialMapper.selectCanteenCpSpecialList(canteenCpSpecial);
    }

    /**
     * 新增菜品规格
     * 
     * @param canteenCpSpecial 菜品规格
     * @return 结果
     */
    @Override
    public int insertCanteenCpSpecial(CanteenCpSpecial canteenCpSpecial)
    {
        return canteenCpSpecialMapper.insertCanteenCpSpecial(canteenCpSpecial);
    }

    /**
     * 修改菜品规格
     * 
     * @param canteenCpSpecial 菜品规格
     * @return 结果
     */
    @Override
    public int updateCanteenCpSpecial(CanteenCpSpecial canteenCpSpecial)
    {
        return canteenCpSpecialMapper.updateCanteenCpSpecial(canteenCpSpecial);
    }

    /**
     * 批量删除菜品规格
     * 
     * @param ids 需要删除的菜品规格主键
     * @return 结果
     */
    @Override
    public int deleteCanteenCpSpecialByIds(Long[] ids)
    {
        return canteenCpSpecialMapper.deleteCanteenCpSpecialByIds(ids);
    }

    /**
     * 删除菜品规格信息
     * 
     * @param id 菜品规格主键
     * @return 结果
     */
    @Override
    public int deleteCanteenCpSpecialById(Long id)
    {
        return canteenCpSpecialMapper.deleteCanteenCpSpecialById(id);
    }

    /**
     * 根据菜品id + 扣减数量
     * 更新：菜品库存数量
     * @param cpId 菜品id
     * @param amount 扣减数量
     * @return
     */
    @Override
    public int reduceCpStock(Long cpId, Integer amount){
        return canteenCpSpecialMapper.reduceCpStock(cpId, amount);
    }
}
